import React, { Component } from 'react'
class Child extends Component {
  state = { test: '测试' }
  render () {
    console.log('child render')
    return (
      <div>child</div>
    )
  }
}
export default class App extends Component {
  childRef = React.createRef()
  render() {
    return (
      <div>
        <button onClick = { () => {
          console.log(this.childRef.current.state.test)
        }}>获取数据</button>
        <Child ref={ this.childRef }/>
      </div>
    )
  }
}
